﻿using Anke.SHManage.Model;
using Anke.SHManage.MSSQLDAL;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anke.SHManage.Web.Reports
{
      
    public partial class CarManage_MaintainPlanModeWebForm : System.Web.UI.Page
    {
        private string PassAmbNumber;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitPage();
            }

            else
            {
                PassAmbNumber = Convert.ToString(ViewState["reportName"]);
            }
        }
        protected void btnSearch_Click1(object sender, EventArgs e)
        {
            BindReportDataSource();

        }
        private void InitPage()
        {
            this.Year.Text = (DateTime.Now.Year).ToString();
           //this.AmbNumber.Text = "H-T0613";
            PassAmbNumber = Request.QueryString["PassAmbNumber"];
            ViewState["reportName"] = PassAmbNumber;
            this.AmbNumber.Text = PassAmbNumber.Length > 0 ? PassAmbNumber : "F-R6215";
            BindReportDataSource();
        }
        protected void BindReportDataSource()
        {

            string Year = Convert.ToString(this.Year.Text);
            string AmbNumber = Convert.ToString(this.AmbNumber.Text).Length>1 ? Convert.ToString(this.AmbNumber.Text) : "";
            this.ReportViewer1.LocalReport.DataSources.Clear();
            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/CM_MaintainPlan.rdlc");
            Microsoft.Reporting.WebForms.ReportParameter st = new Microsoft.Reporting.WebForms.ReportParameter("AmbNumber", AmbNumber);
            this.ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { st });


            CMTJDAL dal = new CMTJDAL();

            DataTable dt = dal.GETYearCGKMaintainPlan(AmbNumber, Year);
            DataTable dt1 = dal.GETYearXEBLJLC(AmbNumber, Year);

            this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dt));
            this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet2", dt1));

            this.ReportViewer1.LocalReport.Refresh();
        }

    }
}